package com.teamwork.module01.controller;

import com.teamwork.common.entity.module01.Class;
import com.teamwork.common.entity.module01.Course;
import com.teamwork.common.result.Result;
import com.teamwork.module01.service.ClassroomService;
import com.teamwork.module01.service.CourseService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/mod01/course")
public class CourseController {
    @Resource
    private CourseService courseService;




    @GetMapping("/getbyname")
    public Result getByname(String name){
        return courseService.getByName(name);
    }
    @GetMapping("/page")
    public Result page(Integer page,Integer size){
        return courseService.getPage(page,size);
    }
    @PostMapping
    public Result InsertOrUpdate(@RequestBody Course course){
        return courseService.InsertOrUpdate(course);
    }
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        return courseService.deleteById(id);
    }
    @DeleteMapping
    public Result batchDelete(List<Integer> ids){
        return courseService.batchDelete(ids);
    }
}
